﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Leadtools.Codecs;
using Leadtools;
using System.Runtime.InteropServices;

namespace Small.PinBan.PB.Comm
{
    /// <summary>
    /// 常用帮助方法
    /// </summary>
    class CommonUtil
    {
        public static RasterImage GetStampPic(string picPath)
        {
            RasterCodecs.Startup();
            RasterCodecs codecs = new RasterCodecs();
            RasterImage image1 = null;
            CodecsThumbnailOptions options = CodecsThumbnailOptions.Default;
            //options.LoadStamp = true;
            //options.Resample = true;
            //options.Width = rasterP1.Width;
            //options.Height = rasterP1.Height;
            //options.MaintainAspectRatio = false;
            try
            {
                //image1 = codecs.ReadThumbnail(picPath, options, 1);
                //options.LoadStamp = false;
                //image1 = codecs.ReadThumbnail(picPath, options, 1);
                image1 = codecs.Load(picPath);
            }
            catch
            {
                options.LoadStamp = false;
                image1 = codecs.ReadThumbnail(picPath, options, 1);
            }
            codecs.Dispose();
            RasterCodecs.Shutdown();

            return image1;
        }

        [DllImport("shell32.dll ")]
        public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);

        [DllImport("kernel32.dll")]
        public static extern int WinExec(string exeName, int operType);

    }
}
